package com.xggstudio.crm.base;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public abstract class BaseFragment  extends Fragment {

    private View view;

    protected abstract int getLayout();

    protected abstract void init(View v);

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView =inflater.inflate(getLayout(),container,false);
        return rootView;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        this.view = view;
        init(view);
    }


    protected void startToActivity(Class<?> lazz){
        Intent intent = new Intent(getActivity(),lazz);
        startActivity(intent);
    }

    protected void startToActivity(Class<?> lazz,Bundle b){
        Intent intent = new Intent(getActivity(),lazz);
        intent.putExtras(b);
        startActivity(intent);
    }


    protected View $(int layoutId){

        return view.findViewById(layoutId);
    }

}
